clear
clc
FIT=zeros(68,6);
COUNTER=zeros(68,6);
SIGMAT=zeros(68,5);

for zz=1:68
    w=load('competitions.mat');
    COMP=w.comp_list(zz,1);
    if isfile(sprintf('Estimates/%s_%02d.mat', 'estimates',COMP))
    load(sprintf('Estimates/%s_%02d.mat', 'estimates',COMP))
    FIT(zz,:)=fit;
    COUNTER(zz,:)=counter;
    SIGMAT(zz,:)=[COMP,sigmaT,sigmaS,q_sp(1),q_team(1)];
    end
end

writematrix(FIT,'fit.csv') 
writematrix(COUNTER,'counterfactual.csv') 
writematrix(SIGMAT,'sigmaT.csv') 

mean(log(COUNTER(COUNTER(:,1)>0,4))-log(COUNTER(COUNTER(:,1)>0,3)))
mean((COUNTER(COUNTER(:,1)>0,6))-(COUNTER(COUNTER(:,1)>0,5)))